{echo:JS::import('dialog?skin=brief');}
{echo:JS::import('dialogtools');}
{echo:JS::import('form');}
<form action="" method="post">
<!-- 
<div class="tools_bar clearfix">

-->
<!-- 
<div class="tools_bar">
-->
	<!-- 
    <a class="icon-checkbox-checked icon-checkbox-unchecked" href="javascript:;" onclick="tools_select('id[]',this)" title="全选" data="true"> 全选 </a>
    -->
    <!-- 
    <a  class="icon-remove-2" href="javascript:;" onclick="tools_submit({action:'{url:/customer/withdraw_del}',msg:'删除后无法恢复，你真的删除吗？'})" title="删除"> 删除</a>
    -->
    <!-- 
    <a class="icon-delicious" href="{url:/customer/withdraw_list}"> 全部记录</a>
    -->
    <!-- 
    <span class="fr"><a href='javascript:;' id="condition" class="icon-search" style="" > 筛选条件</a><input id="condition_input" type="hidden" name="condition" value="{$condition}"></span>
   -->
   <!-- 
</div>
-->
<div style="height:33px;">
	<select style="height:30px;" id="sel_buy_or_sell">
		<option value="buy">买方</option>
		<option value="sell">卖方</option>
	</select>
	<input type="text" placeholder='请输入用户名' id="txt_username"/>
	<input type="button" value="查询" onclick="search()"/>
</div>
<table class="default" >
    <tr>
        <th>时间</th>
        <th>卖家</th>
        <th>买家</th>
        <th>单价</th>
        <th>数量</th>
        <th>总价</th>
        <th>反哺费</th>
        <th>卖家到帐</th>
        <th>买家到帐</th>   
    </tr>
     
    {query:name=transaction_buy where=$where id=$obj page=1 order=id desc pagesize=20}
        <tr>
        	<td>{$item['create_time']}</td>
        	<td>{echo:Common::get_user_obj($item['seller_id'])['name']}</td>
        	<td>{echo:Common::get_user_obj($item['user_id'])['name']}</td>
        	<td>{$item['price']}</td>
        	<td>{$item['quantity']}</td>
        	<td>{echo:$item['price']*$item['quantity']}</td>
        	<td>{$item['fbf_je']}</td>
        	<td>{$item['sell_dz_je']}</td>
        	<td>{$item['buy_dz_je']}</td>
        </tr>
    {/query}
</table>
</form>
<div class="page_nav">
{echo:$obj->pageBar()}
</div>
<script type="text/javascript">
    var form =  new Form();
    $("#condition").on("click",function(){
        $("body").Condition({input:"#condition_input",okVal:'高级搜索',callback:function(data){tools_submit({action:'{url:/customer/buy_sell_list}',method:'get'});},data:{'us.name':{name:'用户名'},'wd.name':{name:'账户名'},'type_name':{name:'名称'},account:{name:'账号'},amount:{name:'提现金额'},'wd.status':{name:'状态',values:{2:'失败',0:'待处理',1:'成功'}}
        }});
    });
    function withdrawAction(id)
    {
        art.dialog.open("{url:/customer/withdraw_view/id/}"+id,{id:'withdraw-dialog',title:"审批",width:620});
    }
    function close_dialog()
    {
        art.dialog({id:"withdraw-dialog"}).close();
        tools_reload();
    }
    
    function search()
    {
    	var buy_or_sell = $('#sel_buy_or_sell').val();
    	var username    = $.trim($("#txt_username").val());
    	if(username != '')
    	{
    		
    		$.post("{url:/customer/get_user_id_by_buy_or_sell}",{username:username},function(result){

    			if(result == '0')
    			{
    				alert('您输入的用户名不存在');
    			}
    			else
    			{
    				if(buy_or_sell == 'buy')
    				{
    					str = "user_id";
    				}
    				else if(buy_or_sell == 'sell')
    				{
    					str = 'seller_id';
    				}
    				document.location.href="{url:/customer/buy_sell_list}&condition=and--"+str+"--eq--"+result;
    			}
    		});
    	}
    	else
    	{
    		document.location.href = "{url:/customer/buy_sell_list}";
    	}
    }
</script>
